// 分类管理相关API
window.categoryAPI = {
    // 获取分类列表
    getCategories: async (params = {}) => {
        try {
            const response = await apiClient.get('/api/categories/', { params });
            return response;
        } catch (error) {
            console.error('获取分类列表失败:', error);
            throw error;
        }
    },
    
    // 获取分类树
    getCategoryTree: async () => {
        try {
            const response = await apiClient.get('/api/categories/tree');
            return response;
        } catch (error) {
            console.error('获取分类树失败:', error);
            throw error;
        }
    },
    
    // 获取分类详情
    getCategory: async (id) => {
        try {
            const response = await apiClient.get(`/api/categories/${id}`);
            return response;
        } catch (error) {
            console.error('获取分类详情失败:', error);
            throw error;
        }
    },
    
    // 创建分类
    createCategory: async (data) => {
        try {
            const response = await apiClient.post('/api/categories', data);
            return response;
        } catch (error) {
            console.error('创建分类失败:', error);
            throw error;
        }
    },
    
    // 更新分类
    updateCategory: async (id, data) => {
        try {
            const response = await apiClient.put(`/api/categories/${id}`, data);
            return response;
        } catch (error) {
            console.error('更新分类失败:', error);
            throw error;
        }
    },
    
    // 删除分类
    deleteCategory: async (id) => {
        try {
            const response = await apiClient.delete(`/api/categories/${id}`);
            return response;
        } catch (error) {
            console.error('删除分类失败:', error);
            throw error;
        }
    }
};
